class_name TerrainChunk

extends ChunkInstance

var pos: Vector3i:
	get:
		return pos
	set(val):
		pos = val
		position = Vector3(pos) * 16.0

func _physics_process(delta: float) -> void:
	if rebake():
		if mesh.get_surface_count() != 0:
			if get_child_count(true) == 0:
				create_trimesh_collision()
			else:
				var shape: CollisionShape3D = get_child(0, true).get_child(0, true)
				shape.shape = mesh.create_trimesh_shape()
